#ifndef PLAYBACKWIDGET_H
#define PLAYBACKWIDGET_H

#include "playbacklist.h"
#include "playbackbottom.h"
#include "playbackprogress.h"
#include "playbackplaybuttongroup.h"
#include "timerangewidget.h"
#include "mytcpsocket.h"
#include "playbackvideowidget.h"

#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QDateEdit>
#include <QPushButton>
#include <QDate>
#include <QComboBox>
#include <QProgressBar>

class PlaybackWidget : public QWidget
{
    Q_OBJECT
public:
    explicit PlaybackWidget(QWidget *parent = nullptr);
private:
    void setSearchUI();
    void setPlaybackUI();
    void setConnect();

    void playIdx(int idx);

    // todo
    // 只实现了回显
    void sendJson(int camerd_id, int channel_id, qint64 start_time, qint64 end_time);




signals:

    void startplay(qlonglong startTime, int cameraId, int channel);

private slots:
    void onSearchClicked();
    void onPlayPause(); // todo
    void on_btnStop_clicked();
    void onSetPosition(int val);

    void onTimeClicked(const QDateTime &timestamp);

    void handleGetTimeRange(Packet packet);

    //void onShowList();
//    void onPlaylistItemClicked();
//    void onPlayPre();
//    void onPlayNext();

private:
    QWidget *playbackWidget;
    QWidget *searchWidget;
    QHBoxLayout *searchLayout;
    QDateEdit *dateEdit;
    QDate date;
    QComboBox *endHourBox;
    QComboBox *endMinuteBox;
    QComboBox *endSecondBox;
    QComboBox *startHourBox;
    QComboBox *startMinuteBox;
    QComboBox *startSecondBox;

    QComboBox *channelBox;
    QComboBox *deviceBox;

    int camera_id = -1;
    int channel_id = -1;

    //QLabel *toLabel;
    QPushButton *searchButton;

    QWidget *progressWidget;
    QVBoxLayout *progressLayout;
    TimeRangeWidget *timerangewidget;
    //QProgressBar *progress;

    //PlaybackList *playbackList; // 播放列表
    PlaybackVideoWidget *playWidget; // 播放画面区域
    PlaybackProgress *playbackProgress; // 进度条
    PlaybackBottom *playbackBottom; // 底部栏
    PlaybackPlayButtonGroup *playbackButtonGroup;

    MyTcpSocket * _socket;


    bool isplay = false;

//    QDateTime lastMouseMoveTime;

};

#endif // PLAYBACKWIDGET_H
